package router

import (
    "asset-management-go/controllers"
    "github.com/gin-contrib/cors"
    "github.com/gin-gonic/gin"
    "time"
)

func SetupRouter() *gin.Engine {
    router := gin.Default()

    router.Use(cors.New(cors.Config{
        AllowOrigins:    []string{"*"},
        AllowMethods:    []string{"GET", "POST", "PUT", "PATCH", "DELETE"},
        AllowHeaders:    []string{"Origin", "Content-Type", "Authorization"},
        ExposeHeaders:   []string{"Content-Length"},
        AllowAllOrigins: true,
        MaxAge:          12 * time.Hour,
    }))

    auth := router.Group("api/auth")
    {
        auth.POST("/login", controllers.Login)
    }

    return router
}
